package com.bwie.controller;

import com.bwie.pojo.Bargaining;
import com.bwie.service.BargainingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/bargaining")
public class BargainingController {

    @Autowired
    private BargainingService bargainingService;

    /**
     * 砍价活动列表
     */
    @RequestMapping("/bargainingList")
    public String bargainingList(Model model){
        List<Bargaining> list = bargainingService.bargainingList();
        model.addAttribute("list",list);
        return "bargaining";
    }

    /**
     * 跳转至详情列表
     */
    @RequestMapping("/goDetails")
    public String goDetails(){
        return "details";
    }

    /**
     *详情界面回显数据
     */
    @RequestMapping("/echo")
    @ResponseBody
    public Bargaining echo(Integer bargainingId){
        return bargainingService.echo(bargainingId);
    }
}
